- /* sdfmodf.cpp by K.Tsuru */
- // function ID = 3008 DRADIX only
- /**********************************************************************
- SDouble class
- SDouble version for "modf".
- It splits 'x' into the integral and decimal parts.
- The integral part of SDecimal 'a' can be obtained by an operator a(0),
- then an SDouble object only can call.
- x = ipart + dpart
- For example
- x = -1.5
- ipart = -1.0
- It returns -1.5 - (-1) = -0.5.
- ***********************************************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- SDouble Modf(const SDouble& x, SDouble& ipart){
- if(x.Type() != x.REAL) x.SetError(x.RADIX_ERR, "Modf", 3008);
- if( (x.NetRdxExp() <= 0) || (x.Sign(3008) == 0) ){
- ipart.SetZero(); //integral part is zero
- return x;
- }
-
- int e = x.RdxExp(); // e > 0
- FigBlock blk;
- uint n_copy = min( (uint)e + 1, x.Size() ); // e+1 > x.Size() is Ok.
-
- blk.size(n_copy, -1); blk.clear(n_copy);
- memcpy(blk.Elements(), x.ReadFigures(), n_copy*sizeof(fType));
- ipart.SetFigBlock(blk, x.Sign(), e);
-
- return x - ipart;
- }
sdfmodf.cpp : last modifiled at 2017/03/13 14:31:59(1,073 bytes)
created at 2017/10/07 10:22:50
The creation time of this html file is 2017/10/07 11:29:39 (Sat Oct 07 11:29:39 2017).